home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Comparable.h
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
- #ifndef __COMPARABLE__
- #define __COMPARABLE__
-
- #ifndef __TYPES__
- #include "Types.h"
- #endif
-
- #ifndef __DIRECTOBJECT__
- #include "DirectObject.h"
- #endif
-
- #pragma push
- #pragma segment Comparable
-
- class ostream;
-
- /***********************************|****************************************/
-
- class AComparable : public TDirectObject
- {
- public:
-
- virtual ~AComparable ();
-
- virtual long Compare ( const AComparable& ) const;
- virtual ostream& operator >> ( ostream& ) const;
-
- // don’t overide these
-
- Boolean operator < ( const AComparable& ) const;
- Boolean operator <= ( const AComparable& ) const;
- Boolean operator == ( const AComparable& ) const;
- Boolean operator != ( const AComparable& ) const;
- Boolean operator >= ( const AComparable& ) const;
- Boolean operator > ( const AComparable& ) const;
-
- protected: AComparable ();
- };
-
- /***********************************|****************************************/
- /***********************************|****************************************/
-
- inline long
- AComparable::Compare ( const AComparable& that ) const
- {
- return (long) this - (long) &that;
- }
-
- /***********************************|****************************************/
-
- inline Boolean
- AComparable::operator < ( const AComparable& that ) const
- {
- return Compare ( that ) < 0;
- }
-
- /***********************************|****************************************/
-
- inline Boolean
- AComparable::operator <= ( const AComparable& that ) const
- {
- return Compare ( that ) <= 0;
- }
-
- /***********************************|****************************************/
-
- inline Boolean
- AComparable::operator == ( const AComparable& that ) const
- {
- return Compare ( that ) == 0;
- }
-
- /***********************************|****************************************/
-
- inline Boolean
- AComparable::operator != ( const AComparable& that ) const
- {
- return Compare ( that ) != 0;
- }
-
- /***********************************|****************************************/
-
- inline Boolean
- AComparable::operator >= ( const AComparable& that ) const
- {
- return Compare ( that ) >= 0;
- }
-
- /***********************************|****************************************/
-
- inline Boolean
- AComparable::operator > ( const AComparable& that ) const
- {
- return Compare ( that ) > 0;
- }
-
- #pragma pop
-
- /***********************************|****************************************/
-
- #endif // __COMPARABLE__